package com.mobi.Survey.facades;

import android.content.Context;
import android.view.View;

import com.mobi.Survey.charts.BarChart.Type;
import com.mobi.Survey.charts.ChartFactory;
import com.mobi.Survey.charts.SimpleSeriesRenderer;
import com.mobi.Survey.charts.XYMultipleSeriesRenderer.Orientation;
import com.mobi.Survey.controller.AggregateResultPojo;

/**
 * 
 * <p>
 * <b>Author:</b> Yahya Arshad
 * <p>
 * <b>Company:</b> Mobi Media Soft
 * <p>
 * <b> Website:</b> www.mobimediasoft.com
 * <p>
 * HorizontalBarChartFacade.java for creating Horizontal bar chart using facade
 * pattern all necessary steps are perform here for creating horizontal bar
 * chart
 * 
 */
public class HorizontalBarChartFacade extends AbstractChart {

	public HorizontalBarChartFacade() {

	}

	public HorizontalBarChartFacade(AggregateResultPojo graphData) {
		super(graphData);
	}

	/**
	 * Returns the chart name.
	 * 
	 * @return the chart name
	 */
	public String getName() {
		return "";
	}

	/**
	 * Returns the chart description.
	 * 
	 * @return the chart description
	 */
	public String getDesc() {
		return "";
	}

	/**
	 * Executes the chart demo.
	 * 
	 * @param context
	 *            the context
	 * @return the built intent
	 */
	public View execute(Context context) {

		String[] titles = new String[] { "" };

		renderer.setOrientation(Orientation.VERTICAL);
		//renderer.setMargins(new int[] { 10, 10, 10, 10 });

		renderer.setYLabels(getValues().size());
		//renderer.setBarSpacing(.2);
		renderer.setShowLabels(true);
		renderer.setShowLegend(false);
		renderer.setPanEnabled(true, false);
		renderer.setShowGridX(true);

		int length = renderer.getSeriesRendererCount();
		for (int i = 0; i < length; i++) {
			SimpleSeriesRenderer seriesRenderer = renderer
					.getSeriesRendererAt(i);
			seriesRenderer.setDisplayChartValues(true);
		}

		return ChartFactory.getBarChartView(context,
				buildBarDataset(titles, getValues()), renderer, Type.DEFAULT);
	}

}
